* C:\Dropbox\Rehm\Data\eurostat\cpi\cpi_eurostat.do

* source: http://ec.europa.eu/eurostat/tgm/table.do?tab=table&init=1&language=en&pcode=tec00118&plugin=1


cd C:\Dropbox\Rehm\Data\eurostat\cpi\

insheet using prc_hicp_aind_1_Data.csv, comma clear

keep if unit=="Annual average index"
tab coicop
drop coicop unit

rename geo country

kountry country, from(other) stuck
rename _ISO3N_ iso3n
kountry iso3n, from(iso3n) to(cown)
rename _COWN_ ccode
tab country if ccode==.
replace ccode=255 if country==`"Germany (until 1990 former territory of the FRG)"'
drop if ccode==.

gen year=time
isid ccode year

kountry ccode, from(cown) to(iso3c)
rename _ISO3C_ iso3c
labmask ccode, val(iso3c)
numlabel ccode, add

rename value cpi
keep ccode year cpi
drop if cpi==":"
destring cpi, replace

cap drop cpi2010
gen cpi2010=.
levelsof ccode, local(C)
foreach c of local C {
	sum cpi if ccode==`c' & year==2010
	replace cpi2010=cpi/`r(mean)' if ccode==`c'
}

xtset ccode year, yearly

drop cpi
label var cpi2010 "CPI (All-items HICP), Eurostat, 2010=1"

compress
note: C:\Dropbox\Rehm\Data\eurostat\cpi\cpi_eurostat.do
note: source: http://ec.europa.eu/eurostat/tgm/table.do?tab=table&init=1&language=en&pcode=tec00118&plugin=1
saveold cpi_eurostat.dta

* C:\Dropbox\Rehm\Data\eurostat\cpi\cpi_eurostat.dta


